From 6d3895e2434e8c219c2fcc9a82795442f5ffec8a Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Fri, 2 Dec 2005 15:35:22 +0000 Subject: [PATCH] Don't log every time around the big transaction writing the device details. This transaction may be starved for a short while, and logging inside the while loop won't help! Use new xstransact.complete to tidy up one other transaction. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/server/DevController.py | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/python/xen/xend/server/DevController.py b/tools/python/xen/xend/server/DevController.py index 94a3784323..814b9405c6 100644 --- a/tools/python/xen/xend/server/DevController.py +++ b/tools/python/xen/xend/server/DevController.py @@ -22,7 +22,7 @@ from xen.xend import sxp from xen.xend.XendError import VmError from xen.xend.XendLogging import log -from xen.xend.xenstore.xstransact import xstransact +from xen.xend.xenstore.xstransact import xstransact, complete from xen.xend.xenstore.xswatch import xswatch DEVICE_CREATE_TIMEOUT = 10 @@ -85,6 +85,8 @@ class DevController: (backpath, frontpath) = self.addStoreEntries(config, devid, back, front) + import xen.xend.XendDomain + count = 0 while True: t = xstransact() try: @@ -97,16 +99,19 @@ class DevController: raise VmError("Device %s is already connected." % dev_str) - log.debug('DevController: writing %s to %s.', str(front), - frontpath) - log.debug('DevController: writing %s to %s.', str(back), - backpath) + if count == 0: + log.debug('DevController: writing %s to %s.', str(front), + frontpath) + log.debug('DevController: writing %s to %s.', str(back), + backpath) + elif count % 50 == 0: + log.debug( + 'DevController: still waiting to write device entries.') t.remove(frontpath) t.remove(backpath) t.mkdir(backpath) - import xen.xend.XendDomain t.set_permissions(backpath, {'dom': xen.xend.XendDomain.PRIV_DOMAIN }, {'dom' : self.vm.getDomid(), @@ -117,6 +122,8 @@ class DevController: if t.commit(): return devid + + count += 1 except: t.abort() raise @@ -273,20 +280,17 @@ class DevController: the device configuration instead. """ path = self.frontendMiscPath() - while True: - t = xstransact(path) - try: - result = t.read("nextDeviceID") - if result: - result = int(result) - else: - result = 0 - t.write("nextDeviceID", str(result + 1)) - if t.commit(): - return result - except: - t.abort() - raise + return complete(path, self._allocateDeviceID) + + + def _allocateDeviceID(self, t): + result = t.read("nextDeviceID") + if result: + result = int(result) + else: + result = 0 + t.write("nextDeviceID", str(result + 1)) + return result def readBackend(self, devid, *args): -- 2.30.2